home *** CD-ROM | disk | FTP | other *** search
/ Macromedia Multimedia Showcase 5.1 / Macromedia - Multimedia Showcase 5.1 (Macromedia) (1996).ISO / pc / media / shared.dir / 02002_Script_navigation object < prev    next >
Text File  |  1996-03-28  |  33KB  |  1,015 lines

  1. -- Nav Object
  2. property sceneID, returnSceneID, navlist, nextlink, menulink, fileName, history,activeBtns, activeLinks, btnInstanceList, curEvent, eventQue, exitQue, mediaList, running, savedTimer, firstBtnSprite, lastBtnSprite,totalLinkSprites, btnOutlineSprite, QTMSprite,timingOut, timeoutDelay, timeoutStartTicks, newDelay, endDelay, returnFrame, returnTime, direction, playIcon, prevCursCast, handCursCast, myClickedSprite, firstNavSprite, pauseSprite, linkY, videoCounter, matchTime,firstLinkSprite, lastLinkSprite, currentSound, musicCastName, fadingOut, musicKilled, pauseBtnCast, pausedStartTicks, musicPlaying, scrollingTextObj, scrollBarSprite, topMaskSprite, bottomMaskSprite, volumeSprite,activeLocators, firstLocatorSprite, MainMenuNum, MainMenuLoc, popUpChannel,FinderObj, flashNextTime, unflashNextTime, nextSprite
  3.  
  4. on birth me
  5.   set QTMSprite = 21 -- QuickTime movies always in sprite 21...
  6.   set savedTimer = 0 -- keeps track of timer when you pause playback in mid-sequence
  7.   set running = true -- run mode or paused mode property
  8.   set newDelay = TRUE
  9.   set endDelay = 0
  10.   set eventQue = [ ]
  11.   set exitQue = [ ]
  12.   set navlist = [:]
  13.   global gRecompileLists
  14.   if gRecompileLists then
  15.     set navlinks = the text of cast "dbase*navigation"
  16.     repeat with i = 1 to the number of lines of navlinks
  17.       set myLine = line i of navlinks
  18.       set myScene = value("#" & item 1 of myLine)
  19.       addProp navlist, myScene, item 2 to 6 of myLine
  20.     end repeat
  21.     put navlist into field "Compiled*Navigation*List"
  22.   else
  23.     set navlist = value(the text of field "Compiled*Navigation*List")
  24.   end if
  25.   
  26.   set history = [:]
  27.   set returnFrame = 0
  28.   set returnTime = 0
  29.   set returnSceneID = #none
  30.   set mediaList = [#B:"DrawBtn",#L:"DrawBtn",#K:"KillLink",#S:"HandleScript",#M:"HandleMarker"]
  31.   
  32.   set btnInstanceList = [:] -- a list that contains the instances of the 'link event object'  
  33.   set activeBtns = [ ]      -- a list that contains currently active buttons
  34.   set activeLinks = [ ]
  35.   set MainMenuNum = 15000
  36.   set MainMenuLoc = "loc" & mainMenuNum
  37.   set activeLocators = [ MainMenuLoc ]
  38.   
  39.   set prevCursCast = the number of cast "curs PREV"
  40.   set handCursCast = the number of cast "curs HAND"
  41.   set pauseBtnCast = the number of cast "btn*pause"
  42.   set playIcon = 0
  43.   set scrollBarSprite = 14
  44.   set topMaskSprite = 16
  45.   set bottomMaskSprite = 17
  46.   set volumeSprite = 26
  47.   set firstLocatorSprite = 27
  48.   set firstNavSprite = 23
  49.   set pauseSprite = 24
  50.   set nextSprite = 25
  51.   set firstBtnSprite = 30
  52.   set lastBtnSprite = 41
  53.   set firstLinkSprite = 42
  54.   set lastLinkSprite = 44
  55.   set totalLinkSprites = lastLinkSprite - firstLinkSprite + 1
  56.   set popUpChannel = 45
  57.   set btnOutlineSprite = 46 -- outlined buttons, lines when clicked
  58.   set myClickedSprite = 0
  59.   set linkY = 464 -- fixed vertical location of links on screen 
  60.   set direction = #none
  61.   InitPuppets(me)
  62.   set musicKilled = FALSE
  63.   set musicPlaying = FALSE
  64.   set scrollingTextObj = ""
  65.   set FinderObj = ""
  66.   set flashNextTime = 0
  67.   set unflashNextTime = 0
  68.   return me
  69. end birth
  70.  
  71. on InitPuppets me  
  72.   set menuSprite = firstNavSprite+4  -- was + 3
  73.   puppetSprite menuSprite, true -- menu button
  74.   set the cursor of sprite menuSprite to [handCursCast,handCursCast+1]
  75.   puppetSprite pauseSprite, true -- pause/play btn
  76.   puppetSprite volumeSprite, TRUE
  77.   set the castNum of sprite volumeSprite = the number of cast ("volume" & the soundLevel)
  78.   repeat with i = firstLocatorSprite to (firstLocatorSprite + 2)
  79.     puppetSprite i, TRUE
  80.   end repeat
  81.   repeat with i = firstBtnSprite to lastBtnSprite
  82.     set the cursor of sprite i to [handCursCast,handCursCast+1]
  83.   end repeat
  84.   repeat with i = firstLinkSprite to lastLinkSprite
  85.     puppetsprite i, true -- declare button sprites as puppets
  86.     set the cursor of sprite i to [handCursCast,handCursCast+1] 
  87.   end repeat
  88.   puppetSprite btnOutlineSprite, TRUE
  89.   repeat with i = firstNavSprite to firstNavSprite + 3
  90.     set the cursor of sprite i to [handCursCast, handCursCast+1]
  91.   end repeat
  92.   puppetTempo 120
  93.   set the keyDownScript = "HandleKeyPress"
  94. end InitPuppets
  95.  
  96. on PrevSeq me
  97.   if not(fadingOut) then
  98.     set myLast = count(history)
  99.     if myLast>1 then
  100.       if returnFrame = 0 then
  101.         set jumpPoint = getPropAt(history,myLast-1)
  102.         set myReturnList = getAt(history,myLast-1)
  103.         set myReturnFrame = getAt(myReturnList,1)
  104.         set myReturnTime = getAt(myReturnList,2)      
  105.         deleteAt(history,myLast)
  106.         -- put "prev:" && jumpPoint      
  107.       else -- returnFrame <> 0, so just jump to beginning of same scene
  108.         set jumpPoint = getPropAt(history,myLast)
  109.       end if
  110.       set direction = #prev
  111.       LoadSeq me, jumpPoint -- pre-emptive load of sequence info
  112.       set returnFrame = myReturnFrame
  113.       set returnTime = myReturnTime
  114.       ChangeScene me, jumpPoint
  115.     end if
  116.   end if  
  117. end PrevSeq
  118.  
  119. on NextSeq me   
  120.   if not(fadingOut) then
  121.     if (timingOut and not(TimeOutExpired(me))) then
  122.       set timingOut = FALSE
  123.       go the frame+1 -- end of scene: show scene exit sequence
  124.     else    
  125.       set jumpPoint = nextlink
  126.       set jumpSceneNum = value(jumpPoint)
  127.       if integerP(jumpSceneNum) and (jumpSceneNum > 0) then
  128.         LoadSeq me, jumpPoint -- pre-emptive load of sequence info
  129.         ChangeScene me, jumpPoint
  130.       else
  131.         doHandlerEvent(me, jumpPoint)
  132.       end if
  133.     end if
  134.   end if
  135. end NextSeq
  136.  
  137. on MenuSeq me
  138.   if not(fadingOut) then
  139.     set jumpPoint = menulink
  140.     set direction = #jump
  141.     LoadSeq me, jumpPoint -- pre-emptive load of sequence info
  142.     ChangeScene me, jumpPoint
  143.   end if
  144. end MenuSeq
  145.  
  146. on HelpSeq me
  147.   if not(fadingOut) then
  148.     set jumpPoint = "82000" -- AUT: hardwired Help starting screen
  149.     set direction = #jump
  150.     StoreReturn me
  151.     LoadSeq me, jumpPoint
  152.     ChangeScene me, jumpPoint
  153.   end if
  154. end HelpSeq
  155.  
  156. on MarkReturn me
  157.   set returnFrame = the frame
  158.   set returnTime = the timer  
  159. end MarkReturn
  160.  
  161. on StoreReturn me
  162.   set returnSceneID = sceneID
  163. end StoreReturn
  164.  
  165. on ReturnFromSequence me
  166.   set jumpPoint = returnSceneID
  167.   set returnSceneID = #none
  168.   LoadSeq me, jumpPoint
  169.   ChangeScene me, jumpPoint
  170. end ReturnFromSequence
  171.  
  172. on StartTimeOut me
  173.   set timeoutStartTicks = the ticks
  174.   set flashNextTime = the ticks + 60
  175.   set unflashNextTime = 0
  176. end StartTimeOut
  177.  
  178. on TimeOutExpired me
  179.   -- checks status of time out at end of scene
  180.   if timingOut then -- timeout sequence in progress
  181.     checkNextFlash(me)
  182.     if (the ticks - timeoutStartTicks) > timeoutDelay then
  183.       return TRUE
  184.     end if
  185.   else
  186.     return FALSE
  187.   end if
  188. end TimeOutExpired
  189.  
  190. on Delay me, duration
  191.   global gMode
  192.   if gMode = #Demo then
  193.     pass
  194.     return 0
  195.   end if
  196.   
  197.   -- delay in a frame script
  198.   if newDelay then
  199.     set newDelay = FALSE
  200.     set endDelay = the ticks + duration*60
  201.   end if
  202.   
  203.   if the ticks <= endDelay then
  204.     UpdateEvents(me)
  205.     UpdateRollover(me)
  206.     set tempScene = value(sceneID)
  207.     if tempScene < 70000 or tempScene > 80000 then
  208.       checkNextFlash(me)
  209.     end if
  210.     go the frame
  211.   else
  212.     set newDelay = TRUE
  213.   end if
  214. end Delay
  215.  
  216. on checkNextFlash me
  217.   if not (flashNextTime or unflashNextTime) then
  218.     set flashNextTime = the ticks + 30
  219.     return
  220.   end if
  221.   if flashNextTime and (the ticks > flashNextTime) then
  222.     puppetsprite nextSprite,TRUE
  223.     set the castNum of sprite nextSprite = the number of cast "next Hilite"
  224.     set flashNextTime = 0
  225.     set unflashNextTime = the ticks + 30
  226.   else
  227.     if unflashNextTime and (the ticks > unflashNextTime) then
  228.       puppetsprite nextSprite,FALSE
  229.       set flashNextTime = the ticks + 120
  230.       set unflashNextTime = 0
  231.     end if
  232.   end if
  233. end checkNextFlash
  234.  
  235. on PauseAnim me, theValue
  236.   -- put #PauseAnim && theValue  
  237.   set movieCast = the castNum of sprite QTMSprite
  238.   set running = theValue
  239.   if running then -- resume playback        
  240.     cursor 0
  241.     set the timer = savedTimer -- restore to saved value of the timer
  242.     set the castNum of sprite pauseSprite = pauseBtnCast
  243.     if musicKilled then
  244.       set musicKilled = FALSE
  245.       PlaySceneMusic me
  246.     end if
  247.     -- ResetNavTimeout() -- reset the timeout delay
  248.     if not(movieCast=0) then
  249.       set the movieRate of sprite QTMSprite = 1
  250.     end if
  251.   else -- pause playback
  252.     if not(fadingOut) then
  253.       set savedTimer = the timer -- store current value of the timer
  254.       set pausedStartTicks = the ticks
  255.       set the castNum of sprite pauseSprite = pauseBtnCast+1
  256.       cursor 0
  257.       if movieCast=0 then -- no QTM sound running
  258.         if musicPlaying then
  259.           puppetsound 0
  260.           set musicKilled = TRUE
  261.           set musicPlaying = FALSE
  262.         end if
  263.       else
  264.         set the movieRate of sprite QTMSprite = 0
  265.       end if
  266.       repeat while true
  267.         if the mouseDown then
  268.           pass
  269.         end if
  270.         UpdateCursors me
  271.         
  272.         updateStage
  273.         --  go the frame
  274.       end repeat
  275.     end if
  276.   end if
  277. end PauseAnim
  278.  
  279. -- need to dynamically check and set cursors while in "PAUSE" mode
  280. -- because of the tight repeat loop in PauseAnim()
  281. on UpdateCursors me  
  282.   -- update pause/play cast (display hilited or not)
  283.   global gMode
  284.   if gMode = #Presentation then checkMainMenuButton
  285.   if ((the ticks - pausedStartTicks)>60) then
  286.     set the castNum of sprite pauseSprite = pauseBtnCast+1+playIcon
  287.     set playIcon = (playIcon+1) mod 2
  288.     set pausedStartTicks = the ticks
  289.   end if
  290.   
  291.   set the locH of sprite btnOutlineSprite = -800
  292.   repeat with i = firstNavSprite to firstNavSprite + 3
  293.     -- prev nav, play/pause, forward nav, Volume control
  294.     if rollover(i) then
  295.       Hilite(me, i)
  296.       cursor [handCursCast,handCursCast+1]
  297.       return 0
  298.     end if
  299.   end repeat
  300.   repeat with i = firstLocatorSprite to (firstLocatorSprite + count(activeLocators))
  301.     if rollover(i) then 
  302.       if not (i = (firstLocatorSprite + 2) and ((sceneID > 80000) or inVision(sceneID))) then
  303.         Hilite(me, i)
  304.         cursor [handCursCast,handCursCast+1]
  305.       end if
  306.       return 0
  307.     end if
  308.   end repeat
  309.   set btnCount = count(activeBtns)
  310.   set lastActiveBtn = firstBtnSprite+btnCount-1  
  311.   repeat with i = firstBtnSprite to lastActiveBtn  -- was -3
  312.     if rollover(i) then
  313.       Hilite(me, i)
  314.       cursor [handCursCast,handCursCast+1]
  315.       return 0
  316.     end if
  317.   end repeat
  318.   
  319.   set linkCount = count(activeLinks)
  320.   set lastActiveLink = firstLinkSprite+linkCount-1
  321.   repeat with i = firstLinkSprite to lastActiveLink    
  322.     -- put #linksRollover && firstLinkSprite && lastActiveLink
  323.     if rollover(i) then      
  324.       Hilite(me, i)
  325.       cursor [handCursCast,handCursCast+1]
  326.       return 0
  327.       -- set the cursor of sprite i to [handCursCast,handCursCast+1]
  328.     end if
  329.   end repeat
  330.   cursor 0
  331. end UpdateCursors
  332.  
  333. on SeqExists me, whichLink
  334.   if whichLink = empty then
  335.     return FALSE
  336.   else
  337.     if voidP(integer(whichLink)) then 
  338.       return FALSE
  339.     else
  340.       return TRUE
  341.     end if
  342.   end if
  343. end SeqExists
  344. -- pre-emptive load of info for the scene which we are about to jump to
  345. -- sets custom switches prior to jumping to the new sequence
  346. -- #NOTE: the value of 'mySequence' is the destination scene ID, which
  347. -- is different from the current scene ID, stored in 'sceneID'
  348. on LoadSeq me, mySequence
  349.   cursor 4
  350.   puppetTransition 0
  351.   set mySequence = value(mySequence)
  352.   -- BtnOutlineStart me -- NH 10/8 enabled again only to colorize btn outlines on user input  
  353.   addProp history, mySequence, [0,0]  -- add goto point to history  
  354.   set myLast = count(history)
  355.   if myLast>1 then
  356.     if mySequence = getPropAt(history,myLast-1) then
  357.       -- put mySequence "already in history"
  358.       deleteAt(history,myLast)
  359.     end if
  360.   end if  
  361.   if not(voidP(getAProp(history, value(sceneID)))) then   
  362.     setProp history, value(sceneID), [returnFrame,returnTime] -- mark frame,time exited  
  363.     -- put "mark RTS:" && returnFrame
  364.   end if
  365.   set returnFrame = 0
  366.   set returnTime = 0
  367.   HandleExitQue(me)  
  368.   getProp(navlist,mySequence)
  369.   set myLinks = the result
  370.   set nextlink = item 1 of myLinks
  371.   set menulink = item 2 of myLinks
  372.   global K -- timeout delay multiplier
  373.   set timeoutDelay = integer(item 3 of myLinks)*60*K
  374.   global gFileSuffix
  375.   set fileName = item 4 of myLinks & gFileSuffix
  376.   set musicCastName = item 5 of myLinks
  377.   
  378.   global gEventList -- load eventQue
  379.   getAProp(gEventList, mySequence)
  380.   set myResult = the result
  381.   if voidP(myResult) then
  382.     set eventQue = [ ]
  383.   else
  384.     set eventQue = value(string(myResult)) -- note: a copy of the list
  385.   end if
  386. end LoadSeq
  387.  
  388. on ChangeScene me, whichFrame
  389.   cursor 4
  390.   set timingOut = FALSE
  391.   set sceneID = whichFrame -- sceneID is current scene's frame label  
  392.   set jumpCommand = "go"
  393.   if returnFrame = 0 then
  394.     set jumpCommand = jumpCommand && quote & string(sceneID) & quote
  395.   else
  396.     set jumpCommand = jumpCommand && "frame" && returnFrame
  397.     -- AUT: delete unneeded items from eventQue here!
  398.   end if  
  399.   set thisMovieName = the movieName
  400.   if not(fileName = thisMovieName) then
  401.     PlaySceneMusic me
  402.     set jumpCommand = jumpCommand && "of movie" && quote & fileName & quote
  403.     AuditBtns(me, whichFrame)
  404.     if the result = #Abort then exit
  405.     ResetQTM(me)
  406.     -- MAKE SURE VOLUME SPRITE STAYS UPDATED!
  407.     set volCast = the number of cast "VolumeCast"
  408.     set curVolLevelCast = the castnum of sprite volumeSprite
  409.     setNewPict(volcast, curVolLevelCast, volumeSprite)
  410.     Do jumpCommand -- make the jump to the new sequence
  411.     InitPuppets(me)
  412.   else
  413.     UpdateBtnsDisplay(me)
  414.     AuditBtns(me, whichFrame)
  415.     if the result = #Abort then exit
  416.     ResetQTM(me)
  417.     BtnOutlineEnd me
  418.     Do jumpCommand -- make the jump to the new sequence    
  419.   end if
  420.   set newDelay = TRUE
  421.   set endDelay = 0
  422.   set flashNextTime = 0
  423.   set unflashNextTime = 0
  424.   puppetSprite nextSprite,FALSE
  425.   set direction = #none
  426.   UpdateBtnsDisplay(me) 
  427.   UpdateLocatorBtns(me)
  428.   
  429.   PauseAnim me, true
  430.   startTimer -- start media synchronization timer
  431.   set the timer = returnTime
  432.   set videoCounter = 10000*(integer(returnTime/10000))
  433. end ChangeScene
  434.  
  435. on WaitForQTM me
  436.   set myCast = the castNum of sprite QTMSprite
  437.   if myCast=0 then
  438.     return FALSE
  439.   else
  440.     set myLength = the duration of cast myCast
  441.     if the movieTime of sprite QTMSprite < myLength then              
  442.       return TRUE
  443.     else -- QTM running, but movie is done        
  444.       return FALSE
  445.     end if
  446.   end if
  447. end WaitForQTM
  448.  
  449. on ResetQTM me
  450.   set the visible of sprite QTMSprite = FALSE    
  451.   updateStage
  452.   set the visible of sprite QTMSprite = TRUE
  453. end ResetQTM
  454.  
  455. -- handle 00000 events and all those with tBirthPtr < returnTime
  456.  
  457. on AuditBtns me, mySequence
  458.   set activeBtns = [ ]
  459.   set activeLinks = [ ]
  460.   global tBirthPtr
  461.   repeat while count(eventQue)>0 -- at least 1 event in this scene
  462.     LoadNextEvent(me)
  463.     if returnTime>=matchTime then 
  464.       global castIdPtr
  465.       set aChar = char 1 of item castIdPtr of curEvent
  466.       if aChar <> "M" then
  467.         set linkType = value("#" & aChar)
  468.         getProp(mediaList, linkType) 
  469.         Do (the result && "me," && quote & curEvent & quote & ", #AuditBtns") 
  470.         -- the result is name of a handler; the matched 'mediaList' value
  471.         if the result = #Abort then
  472.           return #Abort
  473.         else deleteAt(eventQue,1)
  474.       else
  475.         deleteAt(eventQue,1)
  476.       end if
  477.     else
  478.       exit repeat
  479.     end if    
  480.   end repeat
  481.   return 1
  482. end AuditBtns
  483.  
  484. on HandleExitQue me
  485.   repeat while count(exitQue)>0
  486.     getAt(exitQue, 1)
  487.     set curEvent = the result   
  488.     Do (curEvent)
  489.     deleteAt(exitQue,1)
  490.   end repeat
  491. end HandleExitQue
  492.  
  493. -- check event que and update media sequencer, screen, etc
  494. on UpdateEvents me  
  495.   if count(eventQue)>0 then -- at least 1 event in this scene
  496.     if the timer >= matchTime then
  497.       -- set whereIAm = the movie
  498.       global castIdPtr
  499.       set linkType = value("#" & char 1 of item castIdPtr of curEvent)
  500.       getProp(mediaList, linkType)
  501.       -- the result is name of a handler; the matched 'mediaList' value
  502.       Do (the result && "me," && quote & curEvent & quote & ", #UpdateEvents")
  503.       if the result <> #Abort then
  504.         deleteAt(eventQue,1)
  505.       end if
  506.       LoadNextEvent(me)
  507.     end if
  508.   end if
  509. end UpdateEvents
  510.  
  511. on LoadNextEvent me
  512.   if count(eventQue)>0 then
  513.     global tBirthPtr
  514.     -- put eventQue
  515.     getAt(eventQue, 1)
  516.     set curEvent = the result
  517.     set matchTime = integer(item tBirthPtr of curEvent)
  518.   else
  519.     set curEvent = #done
  520.   end if    
  521. end LoadNextEvent
  522.  
  523. on DrawBtn me, whatEvent, caller
  524.   -- put "AssignBtn / DrawBtn" && whatEvent
  525.   global castIdPtr
  526.   set castID = item castIdPtr of whatEvent
  527.   -- test to see if this link's instance already exists
  528.   getaProp btnInstanceList, value("#" & castID)
  529.   set myInstance = the result
  530.   if voidP(myInstance) then
  531.     set myInstance = birth(script "button object", whatEvent)
  532.     addProp btnInstanceList, value("#" & castID), myInstance
  533.   else
  534.     Assign(myInstance, whatEvent)
  535.   end if
  536.   -- update the display
  537.   if castID contains "L" then
  538.     add activeLinks, castID
  539.     if caller = #UpdateEvents then -- caller can also be #AuditBtns
  540.       UpdateBtnsDisplay(me)
  541.     end if
  542.   else -- "B" type of button
  543.     add activeBtns, castID -- add button to active button list   
  544.   end if
  545. end DrawBtn
  546.  
  547. on KillLink me, whatEvent
  548.   global castIdPtr
  549.   set castID = item castIdPtr of whatEvent
  550.   put "L" into char 1 of castID
  551.   getPos activeLinks, castID  
  552.   deleteAt activeLinks, the result
  553.   UpdateBtnsDisplay(me) -- update the links on the screen
  554. end KillLink
  555.  
  556. on HandleMarker me, whatEvent
  557.   -- deal with a marker within a sequence (media transition)
  558.   go marker(1)
  559. end HandleMarker
  560.  
  561. on HandleScript me, theEvent, caller
  562.   global scriptPtr
  563.   set myHandler =  item scriptPtr of theEvent
  564.   if the number of words of myHandler > 1 then
  565.     set paramList =""
  566.     repeat with parameter = 2 to the number of words of myHandler
  567.       put "," & QUOTE & word parameter of myHandler & QUOTE after paramList
  568.     end repeat
  569.     do (word 1 of myHandler && "me" & paramList & ", #" & caller)
  570.   else
  571.     do(myHandler && "me, #" & caller)
  572.   end if
  573. end HandleScript
  574.  
  575. on DeleteFromHistory me
  576.   Add exitQue, "deleteFromNav me" 
  577. end DeleteFromHistory
  578.  
  579. on AlwaysDeleteFromHistory me
  580.   Add exitQue, "deleteFromNav(me, #Always)"
  581. end AlwaysDeleteFromHist
  582.  
  583. on deleteFromNav me, when
  584.   if direction = #none or when = #Always then
  585.     set myLast = count(history)
  586.     deleteAt(history,myLast-1)
  587.   end if
  588. end deleteFromNav
  589.  
  590. on UpdateBtnsDisplay me
  591.   set leftMargin = 385
  592.   set linksAlive = count(activeLinks) 
  593.   
  594.   repeat with i = 1 to linksAlive
  595.     getAt activeLinks, i
  596.     set castID = the result
  597.     set currentSprite = firstLinkSprite-1+i
  598.     set the castNum of sprite currentSprite = cast castID
  599.     set the rect of sprite currentSprite = the rect of cast castID        
  600.     set currentWidth = the width of cast castID
  601.     set the locH of sprite currentSprite = leftMargin+(currentWidth/2)
  602.     set the locV of sprite currentSprite = linkY
  603.     set leftMargin = leftMargin + currentWidth
  604.   end repeat
  605.   
  606.   repeat with i = linksAlive+1 to totalLinkSprites+1
  607.     set currentSprite = firstLinkSprite-1+i
  608.     set the locH of sprite currentSprite = -400
  609.   end repeat
  610. end UpdateBtnsDisplay
  611.  
  612. on UpdateLocatorBtns me 
  613.   global gLocatorList, activeLocators
  614.   set sceneString = string(sceneID)
  615.   set val = value(sceneString)
  616.   if val > 80000 and val < 95000 then
  617.     set activeLocators = getEndLocators(val)
  618.   else 
  619.     if (inVision(val)) then
  620.       if val >= 95000 then
  621.         set activeLocators = [ MainMenuLoc, "loc95000" ]
  622.       else 
  623.         set activeLocators = [ MainMenuLoc, "loc29000" ]
  624.       end if 
  625.     else 
  626.       set activeLocators = [ MainMenuLoc ]
  627.       sort gLocatorList
  628.       set MainMenuList = getAt(gLocatorList, 1)
  629.       set closeLoc = findPosNear(gLocatorList, sceneString)
  630.       set LocFound = getPropAt(gLocatorList, closeLoc)
  631.       set LocInMainMenu = integerP(getAProp(MainMenuList,sceneString))
  632.       if LocFound = sceneString or LocInMainMenu then
  633.         -- going to scene with a level 1 locator
  634.         if (closeLoc > 1) or LocInMainMenu then  -- don't add 'Main Menu' to list again.
  635.           append(activeLocators, ("loc" & sceneString))
  636.         end if
  637.       else
  638.         if LocFound > sceneString and closeLoc > 2 then
  639.           set closeLoc = closeLoc - 1
  640.           set LocFound = getPropAt(gLocatorList, closeLoc)
  641.         end if
  642.         if LocFound <= sceneString and closeLoc > 1 then
  643.           append(activeLocators, ("loc" & LocFound))
  644.           set Level2List = getProp(gLocatorList,LocFound)
  645.           set LocFound2 = 0
  646.           repeat with i = 1 to count(Level2List)
  647.             set thisOne = getPropAt(Level2List, i)
  648.             if thisOne > LocFound2 and thisOne <= sceneString then
  649.               set LocFound2 = thisOne
  650.             end if
  651.           end repeat
  652.           if LocFound2 > 0 and LocFound2 <= sceneString then
  653.             append(activeLocators,("loc" & LocFound2))
  654.           end if
  655.         end if
  656.       end if
  657.     end if
  658.   end if
  659.   set tempLocList = value(string(activeLocators))  -- copy of list
  660.   set val = value(sceneString)
  661.   if val >= 77200 and val < 80000 then setAt (tempLocList, 3, "loc77200") --???
  662.   if (val < 80000) and not (inVision(val)) then  --  or val >= 95000
  663.     append(tempLocList, "LocEmpty")
  664.   end if
  665.   append(tempLocList, "LocBlack")
  666.   repeat with i = 1 to 3
  667.     set nextCast = getAt(tempLocList, i)
  668.     set nextCastNum = the number of cast nextCast
  669.     set the castNum of sprite (firstLocatorSprite + i - 1) to nextCastNum
  670.   end repeat
  671.   updateStage
  672. end UpdateLocatorBtns
  673. -- click on a generic button (message sent by score script):
  674.  
  675. on ClickBtn me
  676.   if not(fadingOut) then
  677.     set mySprite = the clickOn
  678.     set myClickedSprite = mySprite
  679.     set myCastID = the castNum of sprite mySprite
  680.     set myCastID = the name of cast myCastID
  681.     set lastLocatorSprite = firstLocatorSprite + 2
  682.     if (mySprite >= volumeSprite) and (mySprite <= lastLocatorSprite) then
  683.       -- clicked on volume, or locator sprite 
  684.       ClickLocator(me, mySprite, myCastID)
  685.     else 
  686.       getaProp btnInstanceList, value("#" & myCastID)
  687.       set myInstance = the result
  688.       set locOrScript = the jumpToID of myInstance 
  689.       if locOrScript contains "#Instant" then
  690.         set mouseMe = TRUE
  691.       else
  692.         set mouseMe = waitForMouseUp(mySprite)
  693.       end if
  694.       if mouseMe then
  695.         if seqExists(me, the jumptoID of myInstance) then
  696.           set direction = #jump 
  697.           GoToLink(myInstance) -- regular jump to sceneID kind of button
  698.         else
  699.           set myScript = the jumpToID of myInstance
  700.           doHandlerEvent(me, myScript)
  701.         end if
  702.       end if
  703.     end if
  704.   end if
  705. end ClickBtn
  706.  
  707. on doHandlerEvent me, myScript
  708.   if the number of words of myScript > 1 then
  709.     set theParams = ""
  710.     repeat with param = 2 to the number of words of myScript
  711.       if param > 2 then put ", " after theParams
  712.       put QUOTE & word param of myScript & QUOTE after theParams
  713.     end repeat
  714.     do (word 1 of myScript && theParams)
  715.   else
  716.     do myScript
  717.   end if
  718. end doHandlerEvent
  719.  
  720. on ClickLocator me, whichSprite, whichCastName 
  721.   if whichSprite = firstLocatorSprite then 
  722.     set gotMe = waitForMouseUp(whichSprite)
  723.     if gotMe then
  724.       JumpSequence(15000) -- AUT: hardwired jump to main menu
  725.     end if
  726.   else
  727.     set whichLocator = ""
  728.     set locatorNum = 0
  729.     if whichCastName starts "volume" then set whichLocator = "Volume"
  730.     if whichCastName starts "loc" and not (whichCastName = "LocBlack") then
  731.       set whichLocPos = (whichSprite - firstLocatorSprite + 1)
  732.       set whichPopUp = getAt(activeLocators, whichLocPos-1)
  733.       set letterCount = the number of chars of whichPopUp
  734.       set locatorNum = char 4 to lettercount of whichPopUp
  735.       set whichLocator = locatorNum
  736.     end if
  737.     if whichLocator <> "" then
  738.       btnOutlineStart(me)
  739.       global gLocatorList
  740.       set sizeLocList = count(getProp(gLocatorList,whichLocator))
  741.       set thePopUpCast = the number of cast ("Pop" & whichLocator)
  742.       set thePopUpH = the locH of sprite whichSprite
  743.       set thePopUpV = the top of sprite whichSprite - ((the height of cast thePopUpCast) / 2)
  744.       set PopUpPt = point(thePopUpH, thePopUpV)
  745.       set thePopUpSelect = doPopUp(me, thePopUpCast, PopUpPt, sizeLocList, whichCastName)
  746.       if thePopUpSelect = 0 then 
  747.         if locatorNum <> 0 then
  748.           set newSceneLocChars = the number of chars of whichCastName
  749.           set newSceneName = char 4 to newSceneLocChars of whichCastName
  750.           set newScene = value(newSceneName)
  751.           if newScene > 0 and newScene <> sceneID then
  752.             LoadSeq me, newScene
  753.             ChangeScene me, newScene
  754.           else
  755.             toggleQT(QTMSprite, 1)
  756.           end if
  757.         end if
  758.       else
  759.         if thePopUpSelect > 0 then
  760.           set LocList = getProp(gLocatorList, whichLocator)
  761.           set sceneOrScript = getOne(LocList, thePopUpSelect)
  762.           -- put "sceneOrScript  = ", sceneOrScript
  763.           if seqExists(me, sceneOrScript) then
  764.             if value(sceneOrScript) <> sceneID then
  765.               set direction = #jump
  766.               LoadSeq(me, sceneOrScript)
  767.               ChangeScene(me, sceneOrScript) 
  768.             else
  769.               toggleQT(QTMSprite, 1)
  770.             end if
  771.           else
  772.             set myScript = sceneOrScript
  773.             doHandlerEvent(me, myScript)
  774.             toggleQT(QTMSprite, 1)
  775.           end if
  776.         else
  777.           toggleQT(QTMSprite, 1)
  778.         end if
  779.       end if
  780.     end if
  781.   end if
  782. end clickLocator
  783.  
  784. on DoPopUp me, aCast, aPoint, numDivisions, clickedCastName
  785.   set PopUpSprite = popupChannel
  786.   set clickSprite = the clickOn
  787.   set PopUpHeight = the height of cast aCast - 2
  788.   set itemHeight = (float(PopUpHeight) / numDivisions)
  789.   set entryTicks = the ticks
  790.   set aCastName = the name of cast aCast
  791.   if ((aCastName contains "volume") or (clickedCastName = "LocEmpty")) then
  792.     set updateTicks = entryTicks
  793.   else set updateTicks = entryTicks -- + 10
  794.   set didUpdate = FALSE
  795.   puppetsprite PopUpSprite, TRUE
  796.   set the castNum of sprite PopUpSprite = aCast
  797.   set the loc of sprite PopUpSprite = aPoint  
  798.   set movieCast = the castNum of sprite QTMSprite
  799.   if not(movieCast=0) then
  800.     set popUpWide = the width of cast aCast / 2
  801.     set popUpHigh = the height of cast aCast / 2
  802.     set x = getAt(aPoint,1)
  803.     set y = getAt(aPoint,2)
  804.     set rect1 = rect(x-popUpWide, y - popUpHigh, x+popUpWide, y+popUpHigh)
  805.     set rect2 = rect(the left of sprite QTMSprite, the top of sprite QTMSprite, the right of sprite QTMSprite, the bottom of sprite QTMSprite)
  806.     if intersect(rect1, rect2) <> rect(0,0,0,0) then
  807.       set the movieRate of sprite QTMSprite = 0
  808.     end if
  809.   end if
  810.   set the stretch of sprite PopUpSprite = FALSE
  811.   repeat while the mouseDown
  812.     if not didUpdate then 
  813.       if the ticks > updateTicks then 
  814.         updateStage
  815.         set didUpdate = TRUE
  816.         exit repeat
  817.       end if
  818.     end if
  819.   end repeat
  820.   if not didUpdate then
  821.     set the locH of sprite PopUpSprite = -1000
  822.     puppetsprite PopUpSprite,FALSE
  823.   end if
  824.   set lastItem = 0
  825.   set popUpTop = the top of sprite PopUpSprite
  826.   repeat while the mouseDown
  827.     if rollover(PopUpSprite) then
  828.       set theItemNum = integer(((the mouseV - PopUpTop) / itemHeight) -.5)
  829.       if (theItemNum >= 0) and (theItemNum < numDivisions) then
  830.         set itemTop = PopUpTop + ((theItemNum) * itemHeight)
  831.         set itemLeft = the left of sprite PopUpSprite
  832.         set itemRight = the right of sprite PopUpSprite
  833.         HiliteRect (me, itemLeft, itemRight, itemTop, itemTop + itemHeight +4)
  834.         updateStage
  835.         set lastItem = theItemNum + 1
  836.       end if
  837.     else
  838.       if rollover(clickSprite) then
  839.         hilite(me, clickSprite)
  840.       else
  841.         unHilite(me)
  842.       end if
  843.       updateStage
  844.       set lastItem = -1
  845.     end if
  846.   end repeat
  847.   set the foreColor of sprite btnOutlineSprite = 0
  848.   set the locH of sprite PopUpSprite = -1000
  849.   puppetSprite PopUpSprite, FALSE
  850.   UnHilite(me)
  851.   updateStage
  852.   if rollover(clickSprite) then return 0
  853.   else return lastItem
  854. end DoPopUp
  855.  
  856. on BtnOutlineStart me
  857.   set the foreColor of sprite btnOutlineSprite = 248
  858. end BtnOutlineStart
  859.  
  860. on BtnOutlineEnd me  
  861.   set the locH of sprite btnOutlineSprite = -800
  862.   set the foreColor of sprite btnOutlineSprite = 0
  863.   set direction = #none
  864. end BtnOutlineEnd
  865.  
  866. on PlaySceneMusic me
  867.   global gMusicOn
  868.   if gMusicOn then    
  869.     if not(currentSound = musicCastName and musicPlaying) then
  870.       set myCast = the castNum of sprite QTMSprite
  871.       if not(myCast=0) then
  872.         set the movieRate of sprite QTMsprite = 0
  873.         sound close 1
  874.       end if
  875.       set currentSound = musicCastName
  876.       set musicPlaying = TRUE
  877.       puppetSound currentSound
  878.       updatestage      
  879.     end if
  880.   end if
  881. end PlaySceneMusic
  882.  
  883. -- Fade out sound -- Prep for QuickTime
  884.  
  885. on StartMusicFadeOut me  
  886.   sound fadeout, 1, 60
  887.   set timeoutStartTicks = the ticks  
  888. end StartMusicFadeOut
  889.  
  890. on MusicFadeOutDone me  
  891.   if musicPlaying then
  892.     if (the ticks - timeoutStartTicks) > 65 then
  893.       puppetsound 0
  894.       set fadingOut = FALSE
  895.       set musicPlaying = FALSE
  896.       return TRUE
  897.     end if
  898.   else
  899.     set fadingOut = FALSE
  900.     return TRUE
  901.   end if
  902. end MusicFadeOutDone
  903.  
  904. on StartQTMEvent me
  905.   set myCast = the castNum of sprite QTMSprite
  906.   set the movieRate of sprite QTMSprite = 1
  907.   set videoCounter = videoCounter+10000
  908.   set the timer = videoCounter
  909. end StartQTMEvent
  910.  
  911. -- dynamic custom cursor and sprite hilite allocation for all touch areas
  912. -- checks for active buttons and links on the screen
  913. -- constantly re-adjusts the range of sprites that are 'hot'
  914. -- (minimizes which sprites are being tested at any given time)
  915.  
  916. on UpdateRollover me    
  917.   global gMode
  918.   if gMode = #Presentation then checkMainMenuButton
  919.   -- set custom cursors for all active buttons and links on screen,
  920.   -- including the help and menu btns
  921.   set the locH of sprite btnOutlineSprite = -800
  922.   
  923.   set btnCount = count(activeBtns)
  924.   set lastActiveBtn = firstBtnSprite+btnCount-1  
  925.   repeat with i = firstNavSprite to (firstNavSprite + 3)
  926.     -- previous navigation, play/pause, forward navigation, Volume control
  927.     if rollover(i) then
  928.       Hilite(me, i)
  929.       return 0
  930.     end if
  931.   end repeat
  932.   repeat with i = firstLocatorSprite to (firstLocatorSprite + count(activeLocators)) 
  933.     if rollover(i) then
  934.       if not (i = (firstLocatorSprite + 2) and ((sceneID > 80000) or inVision(sceneID))) then
  935.         Hilite(me, i)
  936.         cursor [handCursCast,handCursCast+1]
  937.       end if 
  938.       return 0
  939.     end if
  940.   end repeat
  941.   repeat with i = firstBtnSprite to lastActiveBtn   -- was firstBtnSprite - 3
  942.     if rollover(i) then      
  943.       Hilite(me, i)      
  944.       return 0
  945.     end if
  946.   end repeat
  947.   
  948.   set linkCount = count(activeLinks)
  949.   set lastActiveLink = firstLinkSprite+linkCount-1
  950.   repeat with i = firstLinkSprite to lastActiveLink    
  951.     if rollover(i) then      
  952.       Hilite(me, i)
  953.       return 0
  954.     end if
  955.   end repeat
  956.   cursor 0
  957. end UpdateRollover
  958.  
  959. on Hilite me, theSprite
  960.   puppetTransition 0
  961.   spriteBox btnOutlineSprite, the left of sprite theSprite, ¼
  962.   the top of sprite theSprite, the right of sprite theSprite, the bottom of sprite theSprite 
  963. end Hilite
  964.  
  965. on HiliteRect me, theLeft, theRight, theTop, theBottom
  966.   puppetTransition 0 
  967.   spriteBox btnOutlineSprite, theLeft, theTop, theRight, theBottom
  968. end HiliteRect
  969.  
  970. on UnHilite me
  971.   set the locH of sprite btnOutlineSprite = -1000
  972. end Unhilite
  973.  
  974. on IfOnMac MacFrame, PCFrame
  975.   global gPlatform, gNavObj
  976.   if gPlatform = #PC then
  977.     set theSceneNum = value(PCFrame)
  978.   else
  979.     set theSceneNum = value(MacFrame)
  980.   end if
  981.   LoadSeq gNavObj, theSceneNum
  982.   ChangeScene gNavObj, theSceneNum
  983. end CheckIfOnMac
  984.  
  985. on AddScrollingText me, textChannel, caller
  986.   if voidP(caller) or caller = 0 then
  987.     set textChannel = 0
  988.   end if
  989.   set ScrollingTextObj = birth(script "Scrolling Text Object", textChannel)
  990.   Add exitQue, "KillScrollingText me" 
  991. end AddScrollingText
  992.  
  993. on KillScrollingText me
  994.   if objectP(ScrollingTextObj) then
  995.     kill(ScrollingTextObj)
  996.     set scrollingTextObj = ""
  997.   end if
  998. end KillScrollingText
  999.  
  1000. on AddFinderObj me, whichFinder, caller
  1001.   if voidP(caller) or caller = 0 then
  1002.     alert "No type given for Finder Object! (should be #ATP or #MAGIC)"
  1003.   else
  1004.     set FinderObj = birth(script "Finder Object", whichFinder)
  1005.     Add exitQue, "KillFinder me" 
  1006.   end if
  1007. end AddScrollingText
  1008.  
  1009. on KillFinder me
  1010.   if objectP(FinderObj) then
  1011.     kill(FinderObj)
  1012.     set FinderObj = ""
  1013.   end if
  1014. end KillFinder
  1015.